package com.nitobi.util
{
	import flash.data.EncryptedLocalStore;
	import flash.utils.ByteArray;
	
	public class Encryption
	{
		public static function writeEncryptedStringSetting(key:String, strToEncrypt:String):void
		{
			var contentToStore:ByteArray = new ByteArray();
			contentToStore.writeUTFBytes(strToEncrypt);
			EncryptedLocalStore.setItem(key, contentToStore);
		}
		
		public static function readEncryptedStringSetting(key:String):String
		{
			var contentToRetrieve:ByteArray = EncryptedLocalStore.getItem(key);
			var decryptedData:String = "";
			
			if (contentToRetrieve != null)
			{
				decryptedData = contentToRetrieve.readUTFBytes(contentToRetrieve.length);
			}
			
			return decryptedData;
		}

	}
}